package edu.pku.sei.modeler.uml.commands.umlclass;

import edu.pku.sei.modeler.model.core.MetaModelElement;
import edu.pku.sei.modeler.model.structure.MetaLink;
import edu.pku.sei.modeler.model.structure.MetaNode;
import edu.pku.sei.modeler.model.uml.Interfaces.Interface;
import edu.pku.sei.modeler.model.uml.Interfaces.InterfaceRealization;

public class UMLInterfaceRealizationCreateCommand extends UMLRealizationCreateCommand {


	public UMLInterfaceRealizationCreateCommand(
			MetaModelElement connectionModel, MetaModelElement sourceModel) {
		super(connectionModel, sourceModel);
	}

	@Override
	public void execute() {
		super.execute();
		InterfaceRealization interfaceRealization = (InterfaceRealization) connectionModel;
		interfaceRealization.getContract().add(targetModel);

	}

	@Override
	public void undo() {
		InterfaceRealization interfaceRealization = (InterfaceRealization) connectionModel;
		interfaceRealization.getContract().remove(targetModel);
		super.undo();
	}
	
	
	@Override
	public boolean canExecute() {
		return (targetModel instanceof Interface) && super.canExecute();
	}
}
